import { mergeMap as _observableMergeMap, catchError as _observableCatch } from 'rxjs/operators';
import { from as _observableFrom, throwError as _observableThrow, of as _observableOf } from 'rxjs';
import { UserVm } from '../login/user.model';
import { IRegisterVm } from './register.model';

export class RegisterVm implements IRegisterVm {

    constructor(data?: IRegisterVm) {
        if (data) {
            for (const property in data) {
                if (data.hasOwnProperty(property)) {
                    (<any>this)[property] = (<any>data)[property];
                }
            }
        }
    }
    username!: string;
    password!: string;
    firstName?: string | null;
    lastName?: string | null;

    static fromJS(data: any): RegisterVm {
        data = typeof data === 'object' ? data : {};
        const result = new RegisterVm();
        result.init(data);
        return result;
    }

    init(data?: any) {
        if (data) {
            this.username = data['username'] !== undefined ? data['username'] : <any>null;
            this.password = data['password'] !== undefined ? data['password'] : <any>null;
            this.firstName = data['firstName'] !== undefined ? data['firstName'] : <any>null;
            this.lastName = data['lastName'] !== undefined ? data['lastName'] : <any>null;
        }
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data['username'] = this.username !== undefined ? this.username : <any>null;
        data['password'] = this.password !== undefined ? this.password : <any>null;
        data['firstName'] = this.firstName !== undefined ? this.firstName : <any>null;
        data['lastName'] = this.lastName !== undefined ? this.lastName : <any>null;
        return data;
    }
}
